package cn.itcast.hotel.controller;


import cn.itcast.hotel.pojo.HotelDoc2;
import cn.itcast.hotel.pojo.dto.hotelDto;
import cn.itcast.hotel.resultFul.PageResult;
import cn.itcast.hotel.service.IHotelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
@Slf4j
@Tag(name = "酒店信息查询接口", description = "提供酒店信息查询相关接口")
public class HotelController {

    @Autowired
    private IHotelService hotelService;

    @PostMapping("/list")
    @Operation(summary = "酒店列表查询", description = "根据条件查询酒店列表信息，支持分页和地理位置排序")
    public PageResult<HotelDoc2> list(@RequestBody @Parameter(description = "酒店查询条件", required = true) hotelDto dto) throws Exception{
        log.info("查询：{}", dto);
        return  hotelService.myList(dto);
    }

    @PostMapping("/filters")
    public Map<String, List<String>> filter(@RequestBody hotelDto dto) throws Exception{
        log.info("filter  -查询：{}", dto);
       return hotelService.filter(dto);
    }

    //自动补全
    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam("key") String pre) throws Exception{
        log.info("suggestion  -查询：{}", pre);
        return hotelService.suggestion(pre);
    }

}
